package com.yuhs.zixing.study.design.pattern.dp002.create.c002.factory.f001;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * @description OrderPizza001
 * 1、披萨的种类有很多 GreekPizza CheesePizza 等
 * 2、披萨的制作有 prepare、bake、cut、box
 * 3、完成披萨店的订购功能
 * @author: yuhs
 * @date 2022/3/30 下午8:49
 */
public class OrderPizza001 {
    public OrderPizza001() {
        Pizza001 pizza = null;
        // 订购披萨的类型
        String orderType;

        do {
            orderType = getType();
            if (orderType.equals("greek")) {
                pizza = new GreekPizza001();
                pizza.setName(" 希腊披萨 ");
            } else if (orderType.equals("cheese")) {
                pizza = new CheesePizza001();
                pizza.setName(" 奶酪披萨 ");
            } else if (orderType.equals("pepper")) {
                pizza = new PepperPizza001();
                pizza.setName("胡椒披萨");
            } else {
                break;
            }
            //输出pizza 制作过程
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();

        } while (true);

    }


    // 写一个方法，可以获取客户希望订购的披萨种类
    private String getType() {
        try {
            BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza 种类:");
            String str = strin.readLine();
            return str;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static void main(String[] args) {
        OrderPizza001 orderPizza001 = new OrderPizza001();
    }


}
